SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE VIEW dbo.vw_ListarColaDeMovimiento
AS
---09/09/2010 Adriana Cambié el Join con Licencia 
SELECT     dbo.tb_ColaDeMovimientos.idCola, dbo.tb_Agentes.Documento, dbo.tb_Agentes.Nombres, dbo.tb_Organizaciones.Nombre AS Organizacion, 
                      dbo.tb_MovimientosDocentes.Descripcion AS Movimiento, dbo.tb_Licencias.Descripcion AS Licencia, dbo.tb_ColaDeMovimientos.Observaciones, 
                      dbo.tb_CausasAltas.Descripcion AS CausaAlta, dbo.tb_ColaDeMovimientos.Fecha1 AS Desde, dbo.tb_ColaDeMovimientos.Fecha2 AS Hasta, 
                      tb_CargosSalariales_1.Regimensalarial, dbo.tb_EstadosDeCola.Descripcion AS Estado, dbo.tb_Plazas.CUPOF, 
                      dbo.tb_PlazasDeMovimiento.idplazasdemovimientos, tb_CargosSalariales_1.cargo
FROM         dbo.tb_Licencias RIGHT OUTER JOIN
                      dbo.tb_Organizaciones RIGHT OUTER JOIN
                      dbo.tb_MovimientosDocentes RIGHT OUTER JOIN
                      dbo.tb_CausasAltas RIGHT OUTER JOIN
                      dbo.tb_Agentes LEFT OUTER JOIN
                      dbo.tb_ColaDeMovimientos ON dbo.tb_Agentes.idAgente = dbo.tb_ColaDeMovimientos.Agente ON 
                      dbo.tb_CausasAltas.idCausaAlta = dbo.tb_ColaDeMovimientos.CausaAlta LEFT OUTER JOIN
                      dbo.tb_Plazas LEFT OUTER JOIN
                      dbo.tb_PlazasDeMovimiento ON dbo.tb_Plazas.idPlaza = dbo.tb_PlazasDeMovimiento.idPlaza ON 
                      dbo.tb_ColaDeMovimientos.idCola = dbo.tb_PlazasDeMovimiento.idCola ON 
                      dbo.tb_MovimientosDocentes.idMovimiento = dbo.tb_ColaDeMovimientos.Movimiento LEFT OUTER JOIN
                      dbo.tb_EstadosDeCola ON dbo.tb_ColaDeMovimientos.Estado = dbo.tb_EstadosDeCola.idEstado ON 
                      dbo.tb_Organizaciones.idOrganizaciones = dbo.tb_Plazas.Organizacion RIGHT OUTER JOIN
                      dbo.tb_CargosSalariales tb_CargosSalariales_1 ON dbo.tb_Plazas.CargoSalarialDefault = tb_CargosSalariales_1.idCargo ON 
                      dbo.tb_Licencias.idLicencia = dbo.tb_ColaDeMovimientos.Licencia


GO
GRANT SELECT ON  [dbo].[vw_ListarColaDeMovimiento] TO [SoloVer]
GO
EXEC sp_addextendedproperty N'MS_DiagramPane1', N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[36] 4[3] 2[44] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1 [50] 4 [25] 3))"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1[50] 2[25] 3) )"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1 [56] 3))"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4 [50] 3))"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1 [56] 4 [18] 2))"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1 [75] 4))"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4))"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 0
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "tb_CargosSalariales_1"
            Begin Extent = 
               Top = 164
               Left = 948
               Bottom = 272
               Right = 1137
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_EstadosDeCola"
            Begin Extent = 
               Top = 334
               Left = 590
               Bottom = 412
               Right = 779
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_Plazas"
            Begin Extent = 
               Top = 11
               Left = 626
               Bottom = 119
               Right = 856
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_PlazasDeMovimiento"
            Begin Extent = 
               Top = 7
               Left = 299
               Bottom = 140
               Right = 495
            End
            DisplayFlags = 280
            TopColumn = 7
         End
         Begin Table = "tb_Agentes"
            Begin Extent = 
               Top = 134
               Left = 301
               Bottom = 242
               Right = 502
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_Licencias"
            Begin Extent = 
               Top = 245
               Left = 304
               Bottom = 353
               Right = 505
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_ColaDeMovimientos"
            Begin Extent = 
               Top = 40
               Left = 23
               Bottom = 500
              ', 'USER', N'dbo', 'VIEW', N'vw_ListarColaDeMovimiento', NULL, NULL
GO
EXEC sp_addextendedproperty N'MS_DiagramPane2', N' Right = 212
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_CausasAltas"
            Begin Extent = 
               Top = 492
               Left = 306
               Bottom = 600
               Right = 508
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_MovimientosDocentes"
            Begin Extent = 
               Top = 390
               Left = 311
               Bottom = 498
               Right = 500
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "tb_Organizaciones"
            Begin Extent = 
               Top = 44
               Left = 960
               Bottom = 152
               Right = 1149
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      RowHeights = 220
      Begin ColumnWidths = 16
         Width = 284
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
         Width = 1440
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 1440
         Alias = 900
         Table = 1170
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End
', 'USER', N'dbo', 'VIEW', N'vw_ListarColaDeMovimiento', NULL, NULL
GO
DECLARE @xp int
SELECT @xp=2
EXEC sp_addextendedproperty N'MS_DiagramPaneCount', @xp, 'USER', N'dbo', 'VIEW', N'vw_ListarColaDeMovimiento', NULL, NULL
GO
